package com.oppo.action;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.oppo.bean.UserBean;
import com.oppo.service.impl.UniqueCheckService;
import com.oppo.tools.MyTools;

@WebServlet("/UniqueCheckControl")
public class UniqueCheckControl extends HttpServlet {
	private static final long serialVersionUID = 1L;
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		UserBean ub = new UserBean();
		String user_id = request.getParameter("user_id");
		ub.setUser_id(new Long(user_id));
		
		List<UserBean> list  = MyTools.getNewInstance(UniqueCheckService.class).getUserInfo(ub);
		if(list != null && list.size() > 0) {
			// ajax响应
			// 响应客户单的请求
			PrintWriter pw = response.getWriter();
			// 将json字符串发回客户端浏览器
			pw.write("用户已存在");
			pw.flush();
			pw.close();
		}
	}

}
